package cn.itcast.jms;

import java.util.Map;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Component;

import cn.itcast.bos.utils.AliSMSUtil;


@Component("smsListner")
public class SmsListener implements MessageListener {

	/**
	  * @Description: 监听短信队列中消息
	  * @return 
	*/
	public void onMessage(Message message) {
		try {
			MapMessage mapMessage = (MapMessage) message;
			String tel = mapMessage.getString("tel");
			String templateCode = mapMessage.getString("templateCode");
			Map<String, Object> templateParam = (Map<String, Object>) mapMessage.getObject("templateParam");
			boolean flag = AliSMSUtil.sendMessge(tel, templateCode, templateParam);
			System.out.println(flag);
		} catch (JMSException e) {
			e.printStackTrace();
		}

	}

}
